import { generateUUID } from '@/utils'
import { localeProps } from '@/components/FormCreate/src/utils'

import LinkOptionSelect from './../components/LinkOptionSelect.vue'
/**
 * 字典选择器规则，如果规则使用到动态数据则需要单独配置不能使用 useSelectRule
 */
export const useLinkSelectRule = () => {
  const label = '链接选择器'
  const name = 'LinkSelect'
  onMounted(() => {})
  return {
    icon: 'icon-doc-text',
    label,
    name,
    rule() {
      return {
        type: name,
        field: generateUUID(),
        title: label,
        info: '',
        $required: false
      }
    },
    props(_, { t }) {
      return localeProps(t, name + '.props', [
        {
          title: '展示数据',
          field: 'options',
          name: 'LinkOptionSelect',
          value: [],
          props: { options: [] },
          inject: true,
          component: LinkOptionSelect,

          on: {
            change(e, option) {
              console.log(option)
              e.api.setValue('options', option)
            }
          }
        }
      ])
    }
  }
}
